$(function() {
    var GUIDE_ORDER_URL = '/ent-portal-war/new_pt_uc/my_lesson/getItemSequential.action';

    var GuidePage = function() {
    }

    GuidePage.prototype.init = function() {
        this.fetchOrder();
    };

    GuidePage.prototype.fetchOrder = function() {
        var that = this;
        $.ajax({
            url: GUIDE_ORDER_URL,
            type: "post",
            cache: false,
            dataType: 'json', 
            success: function(rs){
                if(rs.flag == 1) {
                    // NPS:满意度；PROTOCOL:协议；GUIDE:新手指导；EXAMPLAN:老学员考试计划；ANNOUNCEMENT:公告
                    var data = rs.data
                    var itemCode = data.itemCode;
                    switch (itemCode) {
                        case 'NPS':
                            openSatisfactionDialog();
                            break;
                        case 'PROTOCOL':
                            $.ajax({
                                url: "new_pt_uc/my_lesson/notProtocolOrdDetailList.action",
                                type: "post",
                                cache: false,
                                success: function(data){
                                    if(data.indexOf("签署协议") > 0){
                                        $("#portocolDiv").html(data);
                                        pops('.partPop1','.mask_x'); //完善协议 
                                    } 
                                    else if(data.indexOf("完善协议") > 0){
                                        $("#portocolDiv2").html(data);
                                        pops('.partPop2','.mask_x'); //完善协议 
                                    } 
                                }
                            });
                            break;
                        case 'GUIDE':
                            window.location.href = "new_pt_uc/my_lesson/guidance.action";
                            break;
                        case 'EXAMPLAN':
                            if(that.osep) {
                                that.osep.destroy()
                            }
                            that.osep = new OldStudentExamPlan();
                            that.osep.showDialog();
                            break;
                        case 'ANNOUNCEMENT':
                            if(that.announcement) {
                                that.announcement.destroy()
                            }
                            that.announcement = new Announcement();
                            that.announcement.showDialog();
                            break;
                    }
                } else {
                    alert(rs.error || '系统忙碌，请稍后再试')
                }
            }  
        })
    };

    GuidePage.prototype.destroy = function() {
    };

    window.GuidePage = GuidePage;
})